package remoteControlSpy;

import os_listener.OS_Listener;


public class ServiceManager 
{
	OS_Listener osl;
	
	/**
	 * A handle to the unique ServiceMangaer instance.
	 */
	static private ServiceManager instance = null;
	//for the singleton
	private static Object someObject=new Object();
	
	private ServiceManager() 
	{
		osl=OS_Listener.getInstance();
	}
	
	 /**
	 * @return The unique instance of this class.
	 */
	static public ServiceManager getInstance() 
	{
		if(null == instance) 
		{
			//to insure that the time slice doesn't cause the creation of 2 instances
			synchronized (someObject) 
			{
				if (null == instance)
					instance = new ServiceManager();
			}
		}
	    return instance;
	}

	void stopTheService()
	{
		if(osl.getStop() == false)
		{
			osl.setStop(true);
			System.out.println("stopped the service");
		}
	}
	
	void pauseTheService()
	{
		osl.setPause(true);
		System.out.println("paused the service");
	}
	
	void  continueTheService()
	{
		osl.setPause(false);
		System.out.println("continued the service");
	}
	
	void  startTheService()
	{
		osl.setStop(false);
		Thread t = new Thread(osl);
		t.start();
		System.out.println("started the service");
	}
	
	
}